Defining Dimensions and Hierarchies
You are now ready to start
defining dimensions and hierarchies to your database. Dimensions are
the building blocks for cubes in SSAS. You start by right-clicking the
Dimensiond object in the Solution Explorer (or choosing Project, New
Dimension). You can create a new (standard) dimension or define a
dimension that is linked to another SSAS cube or database.
For this example, you will
be creating three new cube dimensions, based on the dimension tables
you have in your data source views (Time_Dimension, Prod_Dimension, Geo_Dimension).
When you choose the New Dimension option, you are welcomed to the
Dimension Wizard. You need to build the new dimensions by using your
data source views. As you can see in Figure 10,
the first wizard dialog prompts you to specify whether you will be
using a data source to create a dimension. This is the wizard build
method. If you haven’t defined any data sources (and perhaps don’t have
them yet), you can use a template approach to define dimensions. This
is the bottom-most option on this dialog. If you want a time dimension
but do not have a previously defined set of tables that represent your
time dimension (in your data source), you can choose the second or
third options to generate a well-formed time representation via this
wizard. We discuss this option later. You do have a valid data source
to use, so you will use the first option to create your first dimension
(which is a Time Dimension based on the Comp Sales 2008 data warehouse/mart Time_Dimension table).
When you choose the first
option (Use an Existing Table), you are prompted to identify the data
source view you want to use to provide data to the new dimension.
Because you have already defined the data source view in a previous
step (the Comp Sales2008 DSV data source view), it should be available for you to use. Figure 11 shows the Comp Sales2008 DSV
data source views and all the tables available for your use. You should
highlight this data source view along with the main table the dimension
will be based on (Time_Dimension table in this case). As you can see in Figure 12, the key columns show up automatically. The fact table’s time is keyed by a pseudo-key called TimeID,
with no other key columns needed. You have a chance to identify any
other columns you might also want to include in this dimension (do not
do so in this example though) and click Next.
You have probably noticed
that the time dimension table has all the other levels of the time
dimension hierarchy as separate columns in it. A few related tables to
this time dimension table hold the member value descriptions that
correspond to each level in the hierarchy. It is really nice to have
the member-level descriptions available in the cube for ease of use by
the end user. It is pretty easy to include these related tables in the
next step of generating this dimension. Figure 13
shows the list of related tables identified earlier in the data source
views. You need to check all the related tables for inclusion in the
time dimension and click Next (they are likely already checked
automatically).
It is now time to select the attributes you want to include in the dimension. As shown in Figure 14,
the Dimension Wizard presents a Dimension Attributes list, along with
the attribute key column and attribute name column correspondences. You
need to identify the correct key column value from your data source
views for Attribute Key Column. You also should enable these attributes
for browsing for your dimension; this essentially makes them available
(surfaces them) in your dimension hierarchy. Notice also that you
identify the types of attribute characteristics. The default is the
Regular attribute for general use. Several other attribute types
correspond to the anticipated behavior or characteristics of the
attribute itself. They might follow date-based behavior, currency type
behavior, or other variations such as slowly changing attributes (and
hence slowly changing dimensions). For this example, you check the
check box for each dimension attribute you need: All Time, Year Time,
Quarter Time, and Month Time, along with the dimension key itself
(TimeID). Then, for the selected dimension attributes, you specify the
attribute type Regular, check the box for enabling these attributes for
browsing, and click Next.
As you can see in Figure 15,
the last step of the dimension generation process shows you the summary
of what you have defined and prompts you to name the dimension you are
about to create (Time_Dimension in this case).
After you click Next, you
are placed in the dimension designer for the dimension you just
created. In addition, a dimension entry is added to the Solution
Explorer, and now you can easily create the hierarchical view for this
dimension. This task is quite easy because all the attributes that
represent a level in a hierarchy are visible (because you enabled
them), and you can simply drag them into a hierarchy from within this
designer. As you can see in Figure 16,
you can click and drag any attribute listed in this dimension from the
Attributes pane (on the far left) to the Hierarchies pane. A new
hierarchy is created automatically when you pull your first attribute
into this work area. Your goal is to create the following hierarchy for
the time dimension (in this order, from top to bottom):
In addition, from this
designer, you can click on the Attribute Relationships tab to see how
the dimension key relates to any of the other attributes you have
defined in the dimension. Usually, there is a correspondence of the key
attribute to each of the hierarchy levels (which show how they can be
used). Figure 17
shows what was generated by the Dimension Wizard. If you need to
specify other attribute relationships, you can easily do so here.
If you want to browse the
data that will make up your dimension that is coming from the data
source, you must first process your dimension (populate the values that
represent the dimension and hierarchy). A process icon (the second
icon) in the upper-left corner of the dimension structure designer
takes you through a two-step process sequence. Step one is to deploy
the definitions and see whether any errors might exist. Step two is to
populate the values (run the processing). If you like, you can do this
now. When this sequence is done, you should be able to open the
Dimension Browser and navigate around in your fully populated dimension
hierarchy (as shown in Figure 18).
You will probably notice
that the data values being displayed in the time hierarchy are numeric.
These are the key values of each level in the hierarchy. If you want to
see the full description of the hierarchy values instead of just the
key values, you can easily modify the properties of each hierarchy
level column’s NameColumn and ValueColumn
properties to have them pull the descriptive (more natural) values from
the related table entries. You simply browse down into the property
window of any level of the hierarchy and update the values with the
corresponding column names of the related table’s description column
name. The window at the top of Figure 19 shows the top-level column (All Times) column properties with nothing identified in it’s NameColumn or ValueColumn properties (actually (none) is the default). The window at the bottom of Figure 19 shows the same properties updated with the corresponding description columns from the corresponding reference table.
You can now update each level
in the hierarchy in the same way (with the corresponding description
column for each time hierarchy level) and then reprocess the dimension.
When you reload the dimension in the Dimension Browser, you see the
full description values displayed, as shown in Figure 20.
That’s it! You have just generated your first usable dimension for the cube!
If you didn’t have such a
well-defined data source set of tables to base your time dimension on,
you could use either of the other two kinds of time dimension options
within this wizard. As you can see in Figure 21,
you need to specify the date periods that will be used when generating
the hierarchies, along with the corresponding attributes (time table
columns). Setting these attributes is relatively standard.
Figure 22
shows the different server time dimension options that Microsoft
provides for your convenience. Microsoft has tried to cover the primary
variations of time dimensions and calendars in the market: Fiscal,
Reporting (for example, for Marketing, which also includes
week-by-month patterns such as 4-4-5 calendars), Manufacturing, and
even ISO 8601 calendars. The process is to first identify a time period
and then select the calendar type to use. The wizard then creates a
server time dimension that meets your needs.
Note
You might want to have
multiple time dimensions in your cube to fulfill multiple business unit
group needs. You can create as many as you need and then provide
perspectives of the cube for each group that include only each group’s
specific time dimension for its needs.